package com.ylxin.service.impl;

import com.ylxin.dao.BookDao;
import com.ylxin.dao.impl.BookDaoImpl;
import com.ylxin.entity.Book;
import com.ylxin.entity.Page;
import com.ylxin.service.BookService;

import java.util.List;

/**
 * @author Hou
 * @version V1.0
 * @Project day42
 * @Package com.qf.service.impl
 * @Description:
 * @Date 2022/5/12 10:47
 */
public class BookServiceImpl implements BookService {
    private BookDao bookDao = new BookDaoImpl();
    @Override
    public List<Book> getAll() {
        return bookDao.selectAll();
    }

    @Override
    public boolean addBook(Book book) {
        return bookDao.addOne(book)>0;
    }

    @Override
    public boolean deleteBook(String bookId) {
        return bookDao.deleteOne(bookId)>0;
    }

    @Override
    public Book getBook(String bookId) {
        return bookDao.selectOne(bookId);
    }

    @Override
    public boolean updateBook(Book book) {
        return bookDao.updateOne(book) > 0;
    }

    @Override
    public List<Book> findAllPage(Page page) {
        List<Book> list = bookDao.selectAllByPage(page);
        return list;
    }

    @Override
    public int findAllPageCount() {
        int count = bookDao.selectAllByPageCount();
        return count;
    }

}
